package com.yinxianren.main.study.httpTest;


import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.util.Base64;
import java.util.Map;
import java.util.TreeMap;

public class PayTest {


    @org.junit.Test
    public void addCus(){
        try {
            Map<String, Object> map = new TreeMap<>();
            map.put("charset","utf-8");
            map.put("signType","MD5");
            map.put("merId","M201001");
            map.put("merOrderId","20190709003");
            map.put("merchantType","00");
            map.put("terminalMerId","M201001-008");
            map.put("terminalMerName","詹光活");
            map.put("userShortName","詹光活");
            map.put("identityType","1");
            map.put("identityNum","350425199006012636");
            map.put("phone","18649624575");
            map.put("province","350000");
            map.put("city","350200");
            map.put("address","厦门翔安");
            map.put("bankCode","ABC");
            map.put("bankCardType","1");
            map.put("cardHolderName","詹光活");
            map.put("bankCardNum","6217001930018496795");
            map.put("bankCardPhone","17605083552");
            map.put("payFee","5");
            map.put("validDate","202011");
            map.put("signMsg", CheckMd5Utils.getMd5SignWithKey(map,"tL6yD1F4"));
            String tradeInfo = JsonUtils.objectToJson(map);
//            System.out.println(tradeInfo);
            tradeInfo= URLEncoder.encode(tradeInfo,"UTF-8");
            String postJson= new String( Base64.getEncoder().encode(tradeInfo.getBytes()),"UTF-8");
            String content = HttpClientUtils.doPostJson(HttpClientUtils.getHttpsClient(), "http://pay.xmfusepay.com/kuaijie/addCusInfo", postJson);
            System.out.println(content);

//            System.out.println(postJson);

        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }}
    @org.junit.Test
    public void bankCardBind(){
        try {
            Map<String, Object> map = new TreeMap<>();
            map.put("charset","utf-8");
            map.put("signType","MD5");
            map.put("merId","M201001");
            map.put("merOrderId","20190709003");
            map.put("bankaccProp","0");
            map.put("identityType","1");
            map.put("identityNum","350425199006012636");
            map.put("bankCardType","1");
            map.put("cardHolderName","詹光活");
            map.put("bankCardNum","6217001930018496795");
            map.put("bankCardPhone","17605083552");
            map.put("province","350000");
            map.put("city","350200");
            map.put("signMsg", CheckMd5Utils.getMd5SignWithKey(map,"tL6yD1F4"));

            String tradeInfo = JsonUtils.objectToJson(map);
//            System.out.println(tradeInfo);
            tradeInfo= URLEncoder.encode(tradeInfo,"UTF-8");
            String postJson= new String( Base64.getEncoder().encode(tradeInfo.getBytes()),"UTF-8");
            String content = HttpClientUtils.doPostJson(HttpClientUtils.getHttpsClient(), "http://pay.xmfusepay.com/kuaijie/bankCardBind", postJson);
            System.out.println(content);

//            System.out.println(postJson);

        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }}
    @org.junit.Test
    public void serviceFul(){
        try {
            Map<String, Object> map = new TreeMap<>();
            map.put("charset","utf-8");
            map.put("signType","MD5");
            map.put("merId","M201001");
            map.put("merOrderId","20190709003");
            map.put("signMsg", CheckMd5Utils.getMd5SignWithKey(map,"tL6yD1F4"));

            String tradeInfo = JsonUtils.objectToJson(map);
//            System.out.println(tradeInfo);
            tradeInfo= URLEncoder.encode(tradeInfo,"UTF-8");
            String postJson= new String( Base64.getEncoder().encode(tradeInfo.getBytes()),"UTF-8");
            String content = HttpClientUtils.doPostJson(HttpClientUtils.getHttpsClient(), "http://pay.xmfusepay.com/kuaijie/serviceFulfillment", postJson);
            System.out.println(content);

//            System.out.println(postJson);

        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }}





    @org.junit.Test
    public void BondCard(){
        try {
            Map<String, Object> map = new TreeMap<>();
            map.put("charset","utf-8");
            map.put("signType","MD5");
            map.put("merId","M201001");
            map.put("merOrderId","20190708001");
            map.put("userName","詹光活");
            map.put("identityType","1");
            map.put("bankCardType","1");
            map.put("identityNum","350425199006012636");
            map.put("bankCardNum","6217001930018496795");
            map.put("bankCardPhone","17605083552");
            map.put("bankCode","CCB");
            map.put("validDate","202011");
            map.put("securityCode","123");
            map.put("terminalMerId","M201001-008");
            map.put("terminalMerName","test");
            map.put("returnUrl","http://...");
            map.put("noticeUrl","http://...");
            map.put("signMsg", CheckMd5Utils.getMd5SignWithKey(map,"tL6yD1F4"));
            String tradeInfo = JsonUtils.objectToJson(map);
//            System.out.println(tradeInfo);
            tradeInfo= URLEncoder.encode(tradeInfo,"UTF-8");
            String postJson= new String( Base64.getEncoder().encode(tradeInfo.getBytes()),"UTF-8");
            String content = HttpClientUtils.doPostJson(HttpClientUtils.getHttpsClient(), "http://pay.xmfusepay.com/kuaijie/bondCard", postJson);
            System.out.println(content);

//            System.out.println(postJson);

        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }}
    @org.junit.Test
    public void confirmBond(){
        try {
            Map<String, Object> map = new TreeMap<>();
            map.put("charset","utf-8");
            map.put("signType","MD5");
            map.put("merId","M201001");
            map.put("merOrderId","20190708001");
            map.put("identityType","1");
            map.put("bankCardType","1");
            map.put("userName","詹光活");
            map.put("identityNum","350425199006012636");
            map.put("bankCardNum","6217001930018496795");
            map.put("bankCode","CCB");
            map.put("bankCardPhone","17605083552");
            map.put("validDate","202011");
            map.put("securityCode","123");
            map.put("payFee","5");
            map.put("backFee","3");
            map.put("backCardNum","6217001930018496795");
            map.put("backBankCode","5");
            map.put("backCardPhone","17605083552");
            map.put("smsCode","911181");
            map.put("terminalMerId","M201001-008");
            map.put("terminalMerName","test");
            map.put("returnUrl","http://...");
            map.put("noticeUrl","http://...");
            map.put("signMsg", CheckMd5Utils.getMd5SignWithKey(map,"tL6yD1F4"));
            String tradeInfo = JsonUtils.objectToJson(map);
//            System.out.println(tradeInfo);
            tradeInfo= URLEncoder.encode(tradeInfo,"UTF-8");
            String postJson= new String( Base64.getEncoder().encode(tradeInfo.getBytes()),"UTF-8");
            String content = HttpClientUtils.doPostJson(HttpClientUtils.getHttpsClient(), "http://pay.xmfusepay.com/kuaijie/confirmBond", postJson);
            System.out.println(content);

//            System.out.println(postJson);

        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }}
    @org.junit.Test
    public void BondCardSms(){
        try {
            Map<String, Object> map = new TreeMap<>();
            map.put("charset","utf-8");
            map.put("signType","MD5");
            map.put("merId","M201002");
            map.put("merOrderId","2019070315390001");
            map.put("userName","詹光活");
            map.put("identityType","1");
            map.put("bankCardType","1");
            map.put("identityNum","35425199006012636");
            map.put("bankCardNum","6217001930018496795");
            map.put("bankCardPhone","17605083552");
            map.put("bankCode","ABC");
            map.put("validDate","202011");
            map.put("securityCode","123");
            map.put("terminalMerId","M201002-009");
            map.put("terminalMerName","test");
            map.put("returnUrl","http://...");
            map.put("noticeUrl","http://...");
            map.put("signMsg", CheckMd5Utils.getMd5SignWithKey(map,"lXN7z498"));
            String tradeInfo = JsonUtils.objectToJson(map);
//            System.out.println(tradeInfo);
            tradeInfo= URLEncoder.encode(tradeInfo,"UTF-8");
            String postJson= new String( Base64.getEncoder().encode(tradeInfo.getBytes()),"UTF-8");
            String content = HttpClientUtils.doPostJson(HttpClientUtils.getHttpsClient(), "http://localhost:8102/kuaijie/reGetBondCode", postJson);
            System.out.println(content);

//            System.out.println(postJson);

        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }}

    @org.junit.Test
    public void payApply(){
        try {
            Map<String, Object> map = new TreeMap<>();
            map.put("bizType","5");
            map.put("charset","utf-8");
            map.put("signType","MD5");
            map.put("merId","M201001");
            map.put("merOrderId","2019070315390002");
            map.put("currency","CNY");
            map.put("amount","10");
            map.put("identityType","1");
            map.put("bankCardType","1");
            map.put("identityNum","350425199006012636");
            map.put("bankCardNum","6217001930018496795");
            map.put("bankCode","CCB");
            map.put("validDate","202211");
            map.put("securityCode","123");
            map.put("bankCardPhone","17605083552");
            map.put("payFee","5");
            map.put("terminalMerId","M201001-008");
            map.put("terminalMerName","test");
            map.put("returnUrl","http://...");
            map.put("noticeUrl","http://...");
            map.put("signMsg", CheckMd5Utils.getMd5SignWithKey(map,"tL6yD1F4"));
            String tradeInfo = JsonUtils.objectToJson(map);
//            System.out.println(tradeInfo);
            tradeInfo= URLEncoder.encode(tradeInfo,"UTF-8");
            String postJson= new String( Base64.getEncoder().encode(tradeInfo.getBytes()),"UTF-8");
            String content = HttpClientUtils.doPostJson(HttpClientUtils.getHttpsClient(), "http://pay.xmfusepay.com/kuaijie/pay/payApply", postJson);
            System.out.println(content);

//            System.out.println(postJson);

        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }}
    @org.junit.Test
    public void confirmPay(){
        try {
            Map<String, Object> map = new TreeMap<>();
            map.put("bizType","5");
            map.put("charset","utf-8");
            map.put("signType","MD5");
            map.put("merId","M201001");
            map.put("merOrderId","2019070315390002");
            map.put("smsCode","568373");
            map.put("terminalMerId","M201001-008");
            map.put("terminalMerName","test");
            map.put("payFee","5");
            map.put("noticeUrl","http://...");
            map.put("signMsg", CheckMd5Utils.getMd5SignWithKey(map,"tL6yD1F4"));
            String tradeInfo = JsonUtils.objectToJson(map);

//            System.out.println(tradeInfo);
            tradeInfo= URLEncoder.encode(tradeInfo,"UTF-8");
            String postJson= new String( Base64.getEncoder().encode(tradeInfo.getBytes()),"UTF-8");
            String content = HttpClientUtils.doPostJson(HttpClientUtils.getHttpsClient(), "http://pay.xmfusepay.com/kuaijie/pay/confirmPay", postJson);
            System.out.println(content);

//            System.out.println(postJson);

        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }}
    @org.junit.Test
    public void confirmPaySms(){
        try {
            Map<String, Object> map = new TreeMap<>();
            map.put("bizType","5");
            map.put("charset","utf-8");
            map.put("signType","MD5");
            map.put("merId","M201002");
            map.put("merOrderId","2019070315390001");
            map.put("terminalMerId","M201002-009");
            map.put("terminalMerName","test");
            map.put("signMsg", CheckMd5Utils.getMd5SignWithKey(map,"lXN7z498"));
            String tradeInfo = JsonUtils.objectToJson(map);

//            System.out.println(tradeInfo);
            tradeInfo= URLEncoder.encode(tradeInfo,"UTF-8");
            String postJson= new String( Base64.getEncoder().encode(tradeInfo.getBytes()),"UTF-8");
            String content = HttpClientUtils.doPostJson(HttpClientUtils.getHttpsClient(), "http://localhost:8102/kuaijie/pay/confirmSMS", postJson);
            System.out.println(content);

//            System.out.println(postJson);

        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }}
    @org.junit.Test
    public void daifu(){
        try {
            Map<String, Object> map = new TreeMap<>();
            map.put("bizType","5");
            map.put("charset","utf-8");
            map.put("signType","MD5");
            map.put("merId","M201001");
            map.put("merOrderId","2019070315390003");
            map.put("originalMerOrderId","2019070315390002");
            map.put("currency","CNY");
            map.put("amount","8");
            map.put("identityType","1");
            map.put("bankCardType","1");
            map.put("identityNum","350425199006012636");
            map.put("bankCardNum","6217001930018496795");
            map.put("bankCardPhone","17605083552");
            map.put("bankCode","CCB");
            map.put("backFee","0.5");
            map.put("terminalMerId","M201001-008");
            map.put("terminalMerName","test");
            map.put("returnUrl","http://...");
            map.put("noticeUrl","http://...");
            map.put("signMsg", CheckMd5Utils.getMd5SignWithKey(map,"tL6yD1F4"));
            String tradeInfo = JsonUtils.objectToJson(map);

//            System.out.println(tradeInfo);
            tradeInfo= URLEncoder.encode(tradeInfo,"UTF-8");
            String postJson= new String( Base64.getEncoder().encode(tradeInfo.getBytes()),"UTF-8");
            String content = HttpClientUtils.doPostJson(HttpClientUtils.getHttpsClient(), "http://inward.xmfusepay.com/kuaijie/getTransOrder", postJson);
            System.out.println(content);

//            System.out.println(postJson);

        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }}


    public static void main(String[] args) {

        BigDecimal a = new BigDecimal("2222222222222222222222222");
        BigDecimal b = new BigDecimal("111111111111111111111");
        BigDecimal c = a.multiply(b);
        System.out.println(c);

    }
}
